<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri = "/struts-tags" prefix = "s"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/js/jquery-1.11.1.js"></script>
<link rel="stylesheet" href="/css/books.css">
<script type="text/javascript">
	$(function(){
		// 初始化遮罩层的代码
		function init(){
			$("#cover").width($(document).width());
			$("#cover").height($(document).height());
		}
		init();
		function initList(){
			var url = "/books.kgy";
			$.post(url,{},function(data, json) {
				var books = $.parseJSON(data);
	        	var str = "";
	        	for (var i = 0; i < books.length; i++) {
	        		str += "<tr>";
	        		str += "<td>"+books[0].id+"</td>";
	        		str += "<td>"+books[0].isbn+"</td>";
	        		str += "<td>"+books[0].name+"</td>";
	        		str += "<td>"+books[0].author+"</td>";
	        		str += "<td>"+books[0].publish+"</td>";
	        		str += "<td>"+books[0].price+"</td>";
	        		str += "<td>"+books[0].currcount+"</td>";
	        		str += "<td>"+books[0].picture+"</td>";
	        		date = new Date(books[0].publishTime.time).toLocaleDateString();
	        		str += "<td>"+date+"</td>";
	        		str += "<td><a href='#'>删除</a></td>";
	        		str += "</tr>";
	        	}
	        	$("tbody").html(str);
			});
		}
		initList();
		
	});
</script>
</head>
<body>
	<div class = "head">
		<s:if test="#session.username == null">
			<a href = "/index.jsp" id = "login">登录</a>
		</s:if>
		<s:else>
			用户名：<s:property value="#session.username"/>
		</s:else>
	</div>
	
	<div class="books">
		<table>
			<caption>图书列表</caption>
			<thead>
				<tr>
					<td>序号</td>
					<td>ISBN</td>
					<td>书名</td>
					<td>作者</td>
					<td>出版社</td>
					<td>售价</td>
					<td>库存</td>
					<td>照片</td>
					<td>出版时间</td>
					<td>删除</td>
				</tr>
			</thead>
			<tbody></tbody>
		</table>
	</div>
	
	<div>
		<form id = "addForm" enctype="">
			isbn:<input type = "text" name = "book.isbn">
			图书名字：<input type = "text" name = "book.name">
			图书作者：<input type = "text" name = "book.author">
			出版社:<input type = "text" name = "book.publish">
			售价:<input type = "text" name = "book.price">
			入库数量:<input type = "text" name = "book.price">
			图书照片:<input type = "file" name = "upload">
			出版时间:<input type = "text" name = "book.publishTime">
			<input type="button" >
		</form>
	</div>
</body>
</html>